package com.buli.blmall.admin.system.controller;

import org.springframework.web.bind.annotation.*;
import com.buli.blmall.admin.system.service.SysUserRoleService;
import com.buli.blmall.admin.system.vo.SysUserRoleVO;
import com.buli.blmall.admin.base.BaseController;
import com.buli.blmall.admin.common.response.Result;
import java.util.List;
import lombok.AllArgsConstructor;


/**
 * <p>
 * 用户角色 控制器
 * </p>
 *
 * @author buli
 * @since 2025-02-27
 */
@RestController
@RequestMapping("system/sys_user_role")
@AllArgsConstructor
public class SysUserRoleController extends BaseController {

    private SysUserRoleService sysUserRoleService;

    /**
     * 查询用户角色详情
     *
     * @param id 用户角色ID
     */
    @GetMapping("/{id}")
    public Result<SysUserRoleVO> getsysUserRole(@PathVariable Long id) {
        return Result.success(sysUserRoleService.info(id));
    }

    /**
     * 查询用户角色集合
     *
     * @param sysUserRoleVo
     */
    @GetMapping("/list")
    public Result<List<SysUserRoleVO>> listSysUserRole(SysUserRoleVO sysUserRoleVo) {
        return Result.success(sysUserRoleService.queryList(sysUserRoleVo));
    }

    /**
     * 添加用户角色
     * @param sysUserRoleVo
     */
    @PostMapping("/add")
    public Result<Boolean> addSysUserRole(@RequestBody SysUserRoleVO sysUserRoleVo) {
        return Result.success(sysUserRoleService.add(sysUserRoleVo));
    }

    /**
     * 修改用户角色
     * @param sysUserRoleVo
     */
    @PutMapping("/edit")
    public Result<Boolean> editSysUserRole(@RequestBody SysUserRoleVO sysUserRoleVo) {
        return Result.success(sysUserRoleService.edit(sysUserRoleVo));
    }

    /**
     * 删除用户角色
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result<Boolean> removeSysUserRole(@PathVariable Long id) {
        return Result.success(sysUserRoleService.removeById(id));
    }

}

